package com.UdpRecieve.service.impl;

import com.UdpRecieve.domain.SysKeyWord;
import com.UdpRecieve.mapper.SysConfigMapper;
import com.UdpRecieve.service.SysKeyWordService;
import com.UdpRecieve.tool.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysKeyWordServiceImpl implements SysKeyWordService {
    @Autowired
    private SysConfigMapper sysSystemConfigMapper;


    @Override
    public List<SysKeyWord> selectSysKeyWordList() {
        return sysSystemConfigMapper.selectAllKW();
    }

    @Override
    public int deleteSysKeyWordListByIds(String ids) {
        Integer[] userIds = Convert.toIntArray(ids);
        return sysSystemConfigMapper.deleteSysKeyWordListByIds(userIds);
    }

    @Override
    public int initKeyWord(SysKeyWord keyWord) {
        int count = sysSystemConfigMapper.selectKWByValue(keyWord.getKeywordValue().trim());
        if (count>0){
            return -2;
        }else {
            return sysSystemConfigMapper.addKeyWords(keyWord);
        }
    }
}
